
//law_stall_organization_holder_verify
/**
 * CREATE TABLE `law_stall_organization_holder_verify` (
 *   `id` int NOT NULL AUTO_INCREMENT COMMENT '审核主键id',
 *   `apply_type_id` int DEFAULT NULL COMMENT '申请类型,1：疏导点，2：摊位，3:摊主',
 *   `object_id` int DEFAULT NULL COMMENT '对应的主键id',
 *   `apply_human_id` int DEFAULT NULL COMMENT '申请人id',
 *   `apply_human_name` varchar(100) DEFAULT NULL COMMENT '申请人姓名',
 *   `verify_human_id` int DEFAULT NULL COMMENT '审核人id',
 *   `verify_human_name` varchar(100) DEFAULT NULL COMMENT '审核人姓名',
 *   `verify_state_id` int DEFAULT NULL COMMENT '审核状态id ,0:待审核 1：审核通过 -1：审核不通过',
 *   `apply_time` datetime DEFAULT NULL COMMENT '申请时间',
 *   `verify_time` datetime DEFAULT NULL COMMENT '审核时间',
 *   `apply_reason` text COMMENT '申请理由',
 *   `verify_opinion` text COMMENT '审核意见',
 *   PRIMARY KEY (`id`),
 *   KEY `idx_lsohv_apply_type_id` (`apply_type_id`)
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='疏导点摊位摊主审核表';
 * @returns {Object}
 */
const verifyData = {
    applyTypeId: 1,
    objectId: 1,
    applyHumanId: 1,
    applyReason: '申请理由'
};

/**
 * law_stall_organization_holder_verify
 * 申请类型,1：疏导点，2：摊位，3:摊主
 * object_id
 * @returns {Promise<unknown>}
 */
function addAuditRecord(verifyData) {

    const insertVerifyRecordSql = [
        ['apply_type_id', `'${verifyData.applyTypeId}'`],
        ['object_id', `'${verifyData.objectId}'`],
        ['apply_human_id', `'${verifyData.applyHumanId}'`],
        ['apply_human_name', 'USER_NAME()'],
        ['apply_reason', `'${recordData.applyReason}'`],
        ['verify_state_id', '0']
    ];

    const formattedFields = insertVerifyRecordSql.map(([key, value]) => {
        return `'${key}',${value}`;
    });

    const law_stall_organization_holder_verify = "ds_tbl:t_1aef92529dae4723ba36422faba4e546";
    const insertSql = `INSERT('${law_stall_organization_holder_verify}', [${formattedFields.join(',')}])`;
    console.log(insertSql);

    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(insertSql).then(res => {
            console.log(res);
            resolve(res);
        })
    })
}
